import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';

export const columns: BasicColumn[] = [
  {
    title: '主题',
    dataIndex: 'matchTopic',
  },
  {
    title: '脚本类型',
    dataIndex: 'scriptType',
  },
  {
    title: '状态',
    dataIndex: 'enable',
    slots: { customRender: 'executeCount' },
  },
  {
    title: '描述',
    dataIndex: 'desc',
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'matchTopic',
    label: '主题',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'scriptType',
    label: '脚本类型',
    component: 'Select',
    colProps: { span: 6 },
    componentProps: {
      options: [
        { label: 'JAVASCRIPT', value: 'JAVASCRIPT' },
        { label: 'GROOVY', value: 'GROOVY' },
        { label: 'LUA', value: 'LUA' },
      ],
    },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: 'id',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    label: '脚本类型',
    field: 'scriptType',
    component: 'Select',
    componentProps: {
      options: [
        { label: 'JAVASCRIPT', value: 'JAVASCRIPT' },
        { label: 'GROOVY', value: 'GROOVY' },
        { label: 'LUA', value: 'LUA' },
      ],
    },
    required: true,
  },
  {
    label: '主题',
    field: 'matchTopic',
    component: 'Input',
    required: true,
  },
  {
    label: '脚本内容',
    field: 'script',
    component: 'JCodeEditor',
    componentProps: {
      height: '240px',
      fullScreen: false,
    },
    required: true,
    defaultValue: 'function convert(topic, payload){\n   return payload;\n}',
  },
  {
    label: '是否启用',
    field: 'enable',
    component: 'JSwitch',
    defaultValue: '1',
    componentProps: {
      options: ['1', '0'],
    },
  },
  {
    field: 'desc',
    label: '描述',
    component: 'Input',
  },
];
